import JSEncrypt from 'jsencrypt'

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCPfMA0d7ui4jCSNK5J6YkLTYKswnkyivxZql1d18tG5keLk31HA7Ai5gYrD9GjpRk5sGCUCGLqjQIG7l+Cf7tuT3D5vbea4qMMPvq9c4NAskqX5ba3DPF2xp6B2vYYhgppcYrC4MMNWibDfWmFpIDGs82pFXRfxqXEVUomL/LZhQIDAQAB'

export function encrypt (v) {
  if (!v) {
    return null
  }
  // 创建加密对象实例
  const encryptor = new JSEncrypt()
  //设置公钥
  encryptor.setPublicKey(publicKey)
  // 对内容进行加密
  return encryptor.encrypt(v)
}